package com.iniapp.app.jsf;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("identity")
@Scope("session")
public class Identity implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private boolean loggedIn;

	private String username;
	private Integer userId;
	
	private List<String> grantedUrls = new ArrayList<String>();
	
	private List<String> grantedActions = new ArrayList<String>();
	
	private boolean isActivated;
	
	private boolean isAuthenticated;
	
	private boolean isForceToChangePassword = false;

	
	public boolean isLoggedIn() {
		return loggedIn;
	}

	public void setLoggedIn(boolean loggedIn) {
		this.loggedIn = loggedIn;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	
	public List<String> getGrantedUrls() {
		return grantedUrls;
	}


	public List<String> getGrantedActions() {
		return grantedActions;
	}
	
	public boolean isExistsInGrantedUrl(String url){
		return JsfSecurityUtil.isUrlMatch(url, getGrantedUrls());
	}

	public void addGrantedAction(String action){
		this.grantedActions.add(action);
	}
	public void addGrantedUrl(String url){
		this.grantedUrls.add(url);
	}
	public void addGrantedActions(List<String> actions){
		this.grantedActions.addAll(actions);
	}

	public void addGrantedUrls(List<String> urls){
		this.grantedUrls.addAll(urls);
	}

	public boolean isActivated() {
		return isActivated;
	}

	public void setActivated(boolean isActivated) {
		this.isActivated = isActivated;
	}

	public boolean isAuthenticated() {
		return isAuthenticated;
	}

	public void setAuthenticated(boolean isAuthenticated) {
		this.isAuthenticated = isAuthenticated;
	}

	public boolean isForceToChangePassword() {
		return isForceToChangePassword;
	}

	public void setForceToChangePassword(boolean isForceToChangePassword) {
		this.isForceToChangePassword = isForceToChangePassword;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	
	
	
}
